package com.communal.web.form.tarif;

import net.sf.ezmorph.bean.MorphDynaBean;
import net.sf.json.JSONObject;

import com.communal.model.tarif.TarifInternet;
import com.communal.web.form.BaseForm;

/**
 * 
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
public class TarifInternetForm extends BaseForm{

	private final String TARIF_NAME = "tarifName";
	private final String TARIF_TYPE = "tarifType";
	private final String UNDER_SUMMA = "underSumma";
	private final String OVER_SUMMA = "overSumma";
	private final String BORDER_VALUE = "borderValue";
	private final String UNLIMIT_SUMMA = "unlimitSumma";
	
	private String tarifName;
	private Short tarifType;
	private Double underSumma;
	private Double overSumma;
	private Short borderValue;
	private Double unlimitSumma;
	
	/**
	 * Constructor from JSON data for {@link TarifElectricityForm} <br>
	 * @param p_data - JSON data
	 */
	public TarifInternetForm(Object p_data) {
		super( p_data, true );
		JSONObject jsonObject = JSONObject.fromObject(p_data);
		MorphDynaBean bean = (MorphDynaBean) JSONObject.toBean(jsonObject);
		tarifName = bean.get(TARIF_NAME).toString();
		tarifType = Short.parseShort(bean.get(TARIF_TYPE).toString());
		underSumma = Double.parseDouble(bean.get(UNDER_SUMMA).toString());
		overSumma = Double.parseDouble(bean.get(OVER_SUMMA).toString());
		borderValue = Short.parseShort(bean.get(BORDER_VALUE).toString());
		unlimitSumma = Double.parseDouble(bean.get(UNLIMIT_SUMMA).toString());
	}
	
	/**
	 * Constructor from internet tarif model <br>
	 * @param p_entity
	 */
	public TarifInternetForm(TarifInternet p_tarifInternet) {
		super( p_tarifInternet );
		tarifName = p_tarifInternet.getTarifName();
		tarifType = p_tarifInternet.getType();
		underSumma = p_tarifInternet.getUnderSumma();
		overSumma = p_tarifInternet.getOverSumma();
		borderValue = p_tarifInternet.getBorderValue();
		unlimitSumma = p_tarifInternet.getUnlimitSumma();
	}

	/**
	 * Returns tarif name <br>
	 * @return {@link String};
	 */
	public String getTarifName() {
		return tarifName;
	}

	/**
	 * Sets tarif name <br>
	 * @param p_tarifName - {@link String};
	 */
	public void setTarifName(String p_tarifName) {
		tarifName = p_tarifName;
	}

	/**
	 * Returns summa which should user pay if he did not exceed month traffic limitation <br>
	 * @return {@link Double};
	 */
	public Double getUnderSumma() {
		return underSumma;
	}

	/**
	 * Sets summa which should user pay if he did not exceed month traffic limitation <br>
	 * @param p_underSumma - {@link Double};
	 */
	public void setUnderSumma(Double p_underSumma) {
		underSumma = p_underSumma;
	}

	/**
	 * Returns summa which should user pay if he exceed month traffic limitation <br>
	 * @return {@link Double};
	 */
	public Double getOverSumma() {
		return overSumma;
	}

	/**
	 * Sets summa which should user pay if he exceed month traffic limitation <br>
	 * @param p_overSumma - {@link Double};
	 */
	public void setOverSumma(Double p_overSumma) {
		overSumma = p_overSumma;
	}

	/**
	 * Returns month traffic limitation <br>
	 * @return {@link Short};
	 */
	public Short getBorderValue() {
		return borderValue;
	}

	/**
	 * Sets month traffic limitation <br>
	 * @param p_borderValue - {@link Short};
	 */
	public void setBorderValue(Short p_borderValue) {
		borderValue = p_borderValue;
	}

	/**
	 * Returns fixed summa for unlimit traffic <br>
	 * @return {@link Double};
	 */
	public Double getUnlimitSumma() {
		return unlimitSumma;
	}

	/**
	 * Sets fixed summa for unlimit traffic <br>
	 * @param p_unlimitSumma - {@link Double};
	 */
	public void setUnlimitSumma(Double p_unlimitSumma) {
		unlimitSumma = p_unlimitSumma;
	}

	/**
	 * Returns tarif type (0 - with limitations; 1 - unlimit) <br>
	 * @return {@link Short};
	 */
	public Short getTarifType() {
		return tarifType;
	}

	/**
	 * Sets tarif type (0 - with limitations; 1 - unlimit) <br>
	 * @param p_tarifType - {@link Short};
	 */
	public void setTarifType(Short p_tarifType) {
		tarifType = p_tarifType;
	}

}
